﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using DevExpress.Skins;
using DevExpress.LookAndFeel;
using DevExpress.UserSkins;
using DevExpress.XtraBars;
using DevExpress.XtraBars.Ribbon;
using DevExpress.XtraBars.Helpers;

namespace NotebookS2.Sales.Layouts
{
    public partial class CHOOSE_LAYOUT : Form
    {
        public CHOOSE_LAYOUT()
        {
            InitializeComponent();
        }

        public string ConnectionString { get; set; }
        public string DocumentNumber { get; set; }

        private void CHOOSE_LAYOUT_Load(object sender, EventArgs e)
        {
            SqlConnection oConnection = new SqlConnection();
            SqlCommand oCommand = new SqlCommand();
            SqlDataAdapter oAdapter = new SqlDataAdapter();

            DataTable dt = new DataTable();

            oConnection.ConnectionString = this.ConnectionString;
            oConnection.Open();

            oCommand.Connection = oConnection;
            oCommand.CommandText = "SELECT * FROM OINVL";

            oAdapter.SelectCommand = oCommand;
            oAdapter.Fill(dt);

            gridControl1.DataSource = dt;
            gridControl1.Refresh();
            gridView1.OptionsBehavior.Editable = false;
            

            
        }

        private void simpleButton1_Click(object sender, EventArgs e)
        {
            try
            {
                SalesInvoice FrmActv = (SalesInvoice)this.ActiveMdiChild;

                string sFile = gridView1.GetRowCellValue(gridView1.FocusedRowHandle, gridView1.Columns["PathFile"]).ToString();

                PRNT_INV oForm = new PRNT_INV();

                oForm.DocumentNumber = this.DocumentNumber;
                oForm.ConnectionString = this.ConnectionString;
                oForm.FileName = sFile;
                oForm.WindowState = FormWindowState.Maximized;

                oForm.ShowDialog();

                oForm.Dispose();
            }
            catch
            {
            }


           
        }

        private void simpleButton2_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
